extends ../layout-wide
block content
    .row
        .col-md-4
            h4.text-center.challenge-instructions-title= name
                 if (isCompleted)
                    | &nbsp;
                    i.ion-checkmark-circled.text-primary(title="Completed")
            hr
            ol
                for step, index in description
                    .row.checklist-element(id="#{dashedName + index}")
                        .col-xs-3.col-sm-1.col-md-2.padded-ionic-icon.text-center
                            input(type='checkbox' class='challenge-list-checkbox')
                        .col-xs-9.col-sm-11.col-md-10
                            li.step-text.wrappable!= step
        .col-xs-12.col-sm-12.col-md-8
            .embed-responsive.embed-responsive-16by9
                iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}')
            br
            if (user)
                a.btn.btn-primary.btn-big.btn-block#completed-zipline-or-basejump 我已经完成了这个挑战 (ctrl + enter)
                script.
                    var userLoggedIn = true;
            else
                a.btn.btn-big.btn-primary.btn-block(href='/challenges/next-challenge?id=' + id) 进入下一个挑战 (ctrl + enter)
            .button-spacer
            .btn-group.input-group.btn-group-justified
                .btn.btn-primary.btn-primary-ghost.btn-big#challenge-help-btn Help
                .btn.btn-primary.btn-primary-ghost.btn-big#trigger-issue-modal Bug
            if (!user)
                .button-spacer
                a.btn.btn-big.signup-btn.btn-block(href='/login') 登录可以保存进度哦
                    script.
                        var userLoggedIn = false;
                br
            script(type="text/javascript").

    #complete-zipline-or-basejump-dialog.modal(tabindex='-1')
        .modal-dialog.animated.fadeIn.fast-animation
            .modal-content
                .modal-header.challenge-list-header= compliment
                    a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
                .modal-body
                    .text-center
                        .animated.zoomInDown
                            span.completion-icon.ion-checkmark-circled.text-primary
                    if (user)
                        form.form-horizontal(name='completedWithForm', id='basejump-or-zipline-submit-form')
                            .form-group.text-center
                                .col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2
                                    // extra field to distract password tools like lastpass from injecting css into our username field
                                    input.form-control.hidden
                                    if (challengeType === "3")
                                        input.form-control#public-url(type="url", name="solutionUrl", placeholder="http://codepen.io/your-pen-here", autofocus, required)
                                    else
                                        input.form-control#public-url(type="url", name="solutionUrl", placeholder="http://yourapp.com", autofocus, required)
                                        input.form-control#github-url(name="githubUrl", placeholder="http://github.com/camper/project")

                    if (user)
                        a.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf) 进入下一个挑战
                        .button-spacer
                        a.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=Check%20out%20the%20project%20I%20just%20built%20with%20%40FreeCodeCamp:%20PASTE_YOUR_CODEPEN_URL_HERE_USING_FULL_INSTEAD_OF_PEN%20%0A%20%23LearnToCode%20%23JavaScript", onclick="ga('send', 'event', 'twitter', 'share', 'challenge completion share');")
                          i.fa.fa-twitter &thinsp;Tweet this project
                    else
                        a.btn.btn-lg.btn-primary.btn-block(href='/challenges/next-challenge?id=' + id) 进入下一个挑战

    include ../partials/challenge-modals
    script.
      var common = window.common || { init: [] };
      common.challengeId = !{JSON.stringify(id)};
      common.challengeName = !{JSON.stringify(name)};
      common.dashedName = !{JSON.stringify(dashedName)};
      common.gaName = !{JSON.stringify(gaName)};
      common.challengeType = !{JSON.stringify(challengeType)};

      common.controlEnterHandler = function (e) {
        $('body').unbind('keydown');
        if (
          e.keyCode === 13 &&
          (e.metaKey || e.ctrlKey)
        ) {
          $('#complete-zipline-or-basejump-dialog').modal('show');
        } else {
          $('body').bind('keydown', common.controlEnterHandler);
        }
      };

      common.modalControlEnterHandler = function (e) {
        $('#complete-zipline-or-basejump-dialog').unbind('keydown');
        if (
          e.keyCode === 13 &&
          (e.metaKey ||  e.ctrlKey)
        ) {
          $('#next-courseware-button').click();
        } else {
          $('#complete-zipline-or-basejump-dialog').on('keydown', common.modalControlEnterHandler);
        }
      };

      common.init.push(function() {
        $('body').on('keydown', common.controlEnterHandler);

        if (!!{ JSON.stringify(user ? true : false)}) {
          $('#complete-zipline-or-basejump-dialog').on('keydown', common.modalControlEnterHandler);
        }

        $('#completed-zipline-or-basejump').on('click', function() {
          $('#complete-zipline-or-basejump-dialog').modal('show');
        });
      });
    include ../partials/challenge-footer
